<template>
  <div>
    {{ localKey }}
    <button @click="init()">init</button>
    <button @click="remove()">remove</button>
  </div>
</template>

<script setup>
import { onMounted, ref } from 'vue';

const localKey = ref('啥都没有');

const init = ()=>{
  localStorage.setItem('local-key', 1)
  localKey.value = localStorage.getItem('local-key')
}
const remove = ()=>{
  localStorage.removeItem('local-key')
  localKey.value = '啥都没有'
}

onMounted(()=>{
if(localStorage.getItem('local-key')){
    localKey.value = localStorage.getItem('local-key')
  }

  init()
})
</script>

<style>

</style>